﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommandReceiver;

namespace ServerTest
{
    class Program
    {
        static TcpServer server = null;

        static void Main(string[] args)
        {
            Console.Write("aaaaa");
            server = new TcpServer(6004);
            server.Accept += new TcpAcceptEventHandler(server_Accept);
            server.Start();
            Console.ReadLine();
        }

        static void server_Accept(object sender, System.Net.Sockets.Socket socket)
        {
            try
            {
                byte[] bs = System.Text.Encoding.Default.GetBytes("ok");
                socket.Send(bs);
                while (true)
                {
                    byte[] receive = new byte[64];
                    socket.Receive(receive);
                    Console.WriteLine(System.Text.Encoding.Default.GetString(receive));
                }
            }
            finally
            {
                socket.Close();
                server.Stop();
            }
        }
    }
}
